/*******************************************************************************
 * Package: com.hngtrust.iir.report.controller
 * Type:    ReportReportController
 * Date:    2021/9/18 15:01
 *
 * Copyright (c) 2021 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.report.controller;

import com.hngtrust.framework.bind.ResponseInfo;
import com.hngtrust.framework.page.PageResult;
import com.hngtrust.iir.dto.ReqDTO;
import com.hngtrust.iir.report.controller.dto.ReportCollectDeleteVO;
import com.hngtrust.iir.report.controller.dto.ReportCollectInsertVO;
import com.hngtrust.iir.report.controller.dto.ReportCollectQueryVO;
import com.hngtrust.iir.report.dto.ReportCollectAndPathDTO;
import com.hngtrust.iir.report.dto.ReportRightUserOrDepartDTO;
import com.hngtrust.iir.report.controller.dto.ReportRightUserOrDepartVO;
import com.hngtrust.iir.report.dto.ReportCommentDTO;
import com.hngtrust.iir.report.controller.dto.ReportCommentInsertVO;
import com.hngtrust.iir.report.controller.dto.ReportCommentQueryVO;
import com.hngtrust.iir.report.controller.dto.ReportLogDTO;
import com.hngtrust.iir.report.controller.dto.ReportLogQueryVO;
import com.hngtrust.iir.report.controller.dto.ReportRightQueryVO;
import com.hngtrust.iir.report.controller.dto.ReportRightUpadteVO;
import com.hngtrust.iir.report.dto.ReportRightDTO;
import com.hngtrust.iir.report.service.ReportCollectionService;
import com.hngtrust.iir.report.service.ReportCommentBacService;
import com.hngtrust.iir.report.service.ReportLogBacService;
import com.hngtrust.iir.report.service.ReportRightBacService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 内部研报-我的（收藏、评论、日志、权限）
 *
 * @author Yujiaqi
 * @date 2021/9/18 15:01
 */
@Slf4j
@RestController
@RequestMapping("/report-my")
@Api(tags = "内部研报-我的（收藏、评论、日志、权限）")
public class ReportMyController {
    @Autowired
    private ReportCollectionService reportCollectionService;
    @Autowired
    private ReportCommentBacService reportCommentService;
    @Autowired
    private ReportLogBacService reportLogBacService;
    @Autowired
    private ReportRightBacService reportRightBacService;
    
    @ApiOperation(value = "内部研报-我的收藏列表", notes = "内部研报-我的收藏列表")
    @PostMapping("/list-collect")
    public ResponseInfo<PageResult<ReportCollectAndPathDTO>> listCollect(
            @ApiParam("内部研报-我的收藏列表") @Valid @RequestBody ReqDTO<ReportCollectQueryVO> reqDTO){
        log.info("ReportCollectionController.listCollect start...");
        PageResult<ReportCollectAndPathDTO> pageResult = reportCollectionService.listCollect(reqDTO);
        return new ResponseInfo(pageResult);
    }
    
    @ApiOperation(value = "内部研报-删除收藏列表", notes = "内部研报-删除收藏列表")
    @PostMapping("/delete-collect")
    public ResponseInfo<ReportCollectDeleteVO> deleteCollect(
            @ApiParam("内部研报-删除收藏列表") @Valid @RequestBody ReportCollectDeleteVO reqDT){
        log.info("ReportCollectionController.deleteCollect start...");
        reportCollectionService.deleteCollect(reqDT);
        return new ResponseInfo(reqDT);
    }
    
    @ApiOperation(value = "内部研报-新增收藏列表", notes = "内部研报-新增收藏列表")
    @PostMapping("/add-collect")
    public ResponseInfo<ReportCollectInsertVO> addCollect(
            @ApiParam("内部研报-新增收藏列表") @Valid @RequestBody ReportCollectInsertVO reqDT){
        log.info("ReportCollectionController.addCollect start...");
        reportCollectionService.addCollect(reqDT);
        return new ResponseInfo(reqDT);
    }
    
    @ApiOperation(value = "内部研报-我的评论列表", notes = "内部研报-我的评论列表")
    @PostMapping("/list-comment")
    public ResponseInfo<ReportCommentDTO> listComment(
            @ApiParam("内部研报-我的评论列表") @Valid @RequestBody ReportCommentQueryVO reportCommentQueryVO){
        log.info("ReportCommentController.listComment start...");
        List<ReportCommentDTO> list = reportCommentService.listComment(reportCommentQueryVO);
        return new ResponseInfo(list);
    }
    
    
    @ApiOperation(value = "内部研报-我的评论新增", notes = "内部研报-我的评论新增")
    @PostMapping("/add-comment")
    public ResponseInfo<ReportCommentInsertVO> addComment(
            @ApiParam("内部研报-我的评论列表") @Valid @RequestBody ReportCommentInsertVO reportCommentInsertVO){
        log.info("ReportCommentController.addComment start...");
        reportCommentService.addComment(reportCommentInsertVO);
        return new ResponseInfo(reportCommentInsertVO);
    }
    
    @ApiOperation(value = "内部研报-研报操作日志列表", notes = "内部研报-研报操作日志列表")
    @PostMapping("/list-log")
    public ResponseInfo<PageResult<ReportLogDTO>> listLog(
            @ApiParam("内部研报-研报操作日志列表") @Valid @RequestBody ReqDTO<ReportLogQueryVO> reqDTO){
        log.info("ReportLogBacController.listLog start...");
        PageResult<ReportLogDTO> pageResult = reportLogBacService.listLog(reqDTO);
        return new ResponseInfo(pageResult);
    }
    
    @ApiOperation(value = "内部研报-研报权限表列表", notes = "内部研报-研报权限表列表")
    @PostMapping("/list-right")
    public ResponseInfo<ReportRightDTO> listRight(
            @ApiParam("内部研报-研报权限表列表") @Valid @RequestBody ReportRightQueryVO reportRightQueryVO){
        log.info("reportRightBacController.listRight start...");
        List<ReportRightDTO> pageResult = reportRightBacService.listRight(reportRightQueryVO);
        return new ResponseInfo(pageResult);
    }
    
    @ApiOperation(value = "内部研报-修改研报权限表", notes = "内部研报-修改研报权限表")
    @PostMapping("/update-right")
    public ResponseInfo<ReportRightUpadteVO> updateRight(
            @ApiParam("内部研报-修改研报权限表") @Valid @RequestBody ReportRightUpadteVO reportRightUpadteVO){
        log.info("reportRightBacController.updateRight start...");
        reportRightBacService.updateRight(reportRightUpadteVO);
        return new ResponseInfo(reportRightUpadteVO);
    }
    
    @ApiOperation(value = "内部研报-权限部门或人员搜索", notes = "内部研报-权限部门或人员搜索")
    @PostMapping("/query-userordepartment")
    public ResponseInfo<List<ReportRightUserOrDepartDTO>> queryUserOrDepartment(
            @ApiParam("内部研报-权限部门或人员搜索") @Valid @RequestBody ReportRightUserOrDepartVO reportRightUserOrDepartVO){
        log.info("reportRightBacController.queryUserOrDepartment start...");
        List<ReportRightUserOrDepartDTO> reportRightUserOrDepartDTO = reportRightBacService.queryUserOrDepartment(reportRightUserOrDepartVO);
        return new ResponseInfo(reportRightUserOrDepartDTO);
    }
    
}
